package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TLotteryRecord;
import com.freesky.biz.icbc.domain.TLotteryRecord618;
import com.freesky.biz.icbc.domain.TSocialCard;
import com.freesky.biz.icbc.service.ILotteryService;
import com.freesky.biz.icbc.service.ISocialCardService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 抽奖活动
 */
@RestController
@RequestMapping("/icbc/lotter")
public class LotteryController extends BaseController {

    @Autowired
    private ILotteryService lotteryService;

    /**
     * 抽奖列表
     */
    @PreAuthorize("@ss.hasPermi('icbc:lottery:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLotteryRecord lotteryRecord) {
        startPage();
        List<TLotteryRecord> list = lotteryService.findList(lotteryRecord);
        return getDataTable(list);
    }

    @Log(title = "抽奖活动", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:lottery:export')")
    @GetMapping("/export")
    public AjaxResult export(TLotteryRecord lotteryRecord,
                             HttpServletResponse response) {
        return lotteryService.exportFile(lotteryRecord);
    }

    @PreAuthorize("@ss.hasPermi('icbc:lottery:list')")
    @GetMapping("/list618")
    public TableDataInfo list618ist(TLotteryRecord618 entity) {
        startPage();
        List<TLotteryRecord618> list = lotteryService.find618List(entity);
        return getDataTable(list);
    }

    @Log(title = "抽奖活动", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:lottery:export')")
    @GetMapping("/export618")
    public AjaxResult export618(TLotteryRecord618 entity,
                             HttpServletResponse response) {
        return lotteryService.export618File(entity);
    }

}
